<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ include file="../header.jsp" %>

	</head>
      <body>
        <div class="container">
        <div class="main-panel">
        <div class="panel panel-default">
        <div class="panel-heading">
            <h2>Edición de tipo de documento</h2>
        </div>
        <div class="panel-body">
        
   	<!-- BEGIN: flash messages -->
    <c:if test="${!sessionScope.hasErrors && sessionScope.successMessage != null}">
    	<div class="alert alert-success"><c:out value="${sessionScope.successMessage}" /></div> 
    </c:if>
    <c:if test="${sessionScope.hasErrors}">
    	<c:forEach items="${sessionScope.errorMessages}" var="message">
    	<div class="alert alert-danger"><c:out value="${message}" /></div>
    	</c:forEach> 
    </c:if>
    <% 
    	session.setAttribute("hasErrors", null);
    	session.setAttribute("successMessage", null);
    	session.setAttribute("errorMessages", null);
    %>
    <!-- END: flash messages -->    

        <form class="form-horizontal" role="form" url="${pageContext.request.contextPath}/tiposDeDocumento/editar" method="POST" >
          <input type="hidden" name="version" value="${documentType.version}" />

          <div class="form-group">
            <label class="col-sm-2 control-label">Nombre</label>
            <div class="col-sm-10">

            <input type="text" class="form-control" id="name" name="name" placeholder="Nombre" value="${documentType.name}">
            </div>
          </div>

          <div class="form-group">
            <label class="col-sm-2 control-label">Purgable</label>
            <div class="col-sm-10">
                <div class="radio">
                  <label>
                    <input type="radio" name="purgeable" id="purgeableTrue" value="true" ${documentType.purgeable ? 'checked' : ''} >
                    Sí
                  </label>
                </div>
                <div class="radio">
                  <label>
                    <input type="radio" name="purgeable" id="purgeableFalse" value="false" ${documentType.purgeable ? '' : 'checked'} >
                    No
                  </label>
                </div>
            </div>
          </div>

          <div class="form-group">
            <label class="col-sm-2 control-label">Tiene vencimiento</label>
            <div class="col-sm-10">
                <div class="radio">
                  <label>
                    <input type="radio" name="hasExpiration" id="hasExpirationTrue" value="true" ${documentType.hasExpiration ? 'checked' : ''} >
                    Sí
                  </label>
                </div>
                <div class="radio">
                  <label>
                    <input type="radio" name="hasExpiration" id="hasExpirationFalse" value="false" ${documentType.hasExpiration ? '' : 'checked'} >
                    No
                  </label>
                </div>
            </div>
          </div>

          <div class="form-group">
            <label class="col-sm-2 control-label">Duración por defecto en meses</label>
            <div class="col-sm-10">
              <input type="number" class="form-control" id="defaultLastingMonths" name="defaultLastingMonths" min="1" max="9999" step="1" value="${documentType.defaultLastingMonths}" /> 
            </div>
          </div>

          <div class="form-group">
            <label class="col-sm-2 control-label">Días de anticipo para notificación</label>
            <div class="col-sm-10">
              <input type="number" class="form-control" id="daysInAdvanceForNotice" min="1" max="1000" step="1" value="${documentType.daysInAdvanceForNotice}" name="daysInAdvanceForNotice" /> 
            </div>
          </div>

          <div class="form-group">
            <label class="col-sm-2 control-label">Correo electrónico para notificación de carga</label>
            <div class="col-sm-10">
              <input type="email" class="form-control" id="uploadNotificationEmailAddress" name="uploadNotificationEmailAddress" placeholder="Dirección de correo electrónico" value="${documentType.uploadNotificationEmailAddress}">
            </div>
          </div>

          <div class="form-group">
            <label class="col-sm-2 control-label">Versionable</label>
            <div class="col-sm-10">
                <div class="radio">
                  <label>
                    <input type="radio" name="versionable" id="versionableTrue" value="true" ${documentType.versionable ? 'checked' : ''} >
                    Sí
                  </label>
                </div>
                <div class="radio">
                  <label>
                    <input type="radio" name="versionable" id="versionable" value="false" ${documentType.versionable ? '' : 'checked'} >
                    No
                  </label>
                </div>
            </div>
          </div>

          <div class="form-group">
            <label class="col-sm-2 control-label">Nombre archivo</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="shortName" placeholder="Nombre de archivo" value="${documentType.shortName}" name="shortName">
            </div>
          </div>

          <input type="submit" class="btn btn-default" value="Actualizar" />

        </form>

        </div>